package com.supor.aiot.home.apdater;

import android.widget.ImageView;

import com.android.baseconfig.base.GlideApp;
import com.supor.aiot.common.entity.BannerInfo;
import com.supor.aiot.common.ui.view.skeleton.SkeletonFrameLayout;
import com.supor.aiot.home.R;
import com.zhpan.bannerview.BaseBannerAdapter;
import com.zhpan.bannerview.BaseViewHolder;

/**
 * ---------------------------------------------------------------- <br>
 * Copyright (C) 2014-2021, by het, ShenZhen, All rights reserved.  <br>
 * ---------------------------------------------------------------- <br>
 * <p>
 * 描述: BannerAdapter <br>
 * 作者: lei <br>
 * 日期: 2021/11/8 <br>
 */
public class BannerAdapter extends BaseBannerAdapter<BannerInfo> {
    @Override
    protected void bindData(BaseViewHolder<BannerInfo> holder, BannerInfo data, int position,
                            int pageSize) {
        if (data.getItemType() == BannerInfo.TYPE_ITEM_NOMAL) {
            ImageView imageView = holder.findViewById(com.supor.aiot.common.R.id.iv_image);
            GlideApp.with(holder.itemView.getContext())
                    .load(data.imageUrl)
                    .into(imageView);
            SkeletonFrameLayout skeletonFrameLayout = (SkeletonFrameLayout) holder.findViewById(R.id.shimmer_view_container);
            skeletonFrameLayout.hideShimmer();
        } else {
            SkeletonFrameLayout skeletonFrameLayout = (SkeletonFrameLayout) holder.findViewById(R.id.shimmer_view_container);
            skeletonFrameLayout.startShimmer();
        }

    }

    @Override
    public int getLayoutId(int viewType) {
        return R.layout.layout_banner_item;
    }
}
